/**
 * Company : SIANGKLOM.
 * Created By : Chatree Siangklom
 * Created On : Oct 4, 2013  3:06:07 PM 
 * e-Mail : dr_chatree@hotmail.com
 * Mobile Phone : (+66) 087-921-5115
 * Package Name : sap.business.commons
 * File Name : SapTableReturn.java
 * TODO
 */
package sap.business.commons;

import java.io.IOException;

import sap.jco.client.Connection;

import com.sap.conn.jco.JCoException;
import com.sap.conn.jco.JCoFunction;
import com.sap.conn.jco.JCoTable;

/**
 * @author Chatree Siangklom of Administrator
 * Date =Oct 4, 2013 : 3:06:07 PM 
 * CreateBy=Chatree Siangklom
 * 
 * SapTableReturn
 * TODO
 */
public class SapTableReturn {

	private String sap_table_return;
	private JCoFunction jCoFunction;
	
	/**
	 * @return the sap_table_return
	 * Date =Oct 4, 2013 : 3:06:38 PM 
	 * CreateBy=Chatree Siangklom
	 * SapTableReturn.java String
	 * TODO
	 */
	public String getSap_table_return() {
		return sap_table_return;
	}

	/**
	 * Date =Oct 4, 2013 : 3:06:07 PM 
	 * CreateBy=Chatree Siangklom
	 * SapTableReturn
	 * TODO
	 */
	public SapTableReturn(String sap_table_return) {
		this.sap_table_return = sap_table_return;
	}

	public SapTableReturn(String sap_table_return, JCoFunction jCoFunction) {
		this.jCoFunction = jCoFunction;
		this.sap_table_return = sap_table_return;
	}

	/**
	 * 
	 * Date =Oct 4, 2013 : 5:32:17 PM 
	 * CreateBy=Chatree Siangklom
	 * JCoTable
	 * TODO
	 * @return
	 * @throws JCoException
	 * @throws IOException
	 * @throws Exception
	 */
	public JCoTable getJCoTable() throws JCoException, IOException, Exception {
		if(jCoFunction == null) 
			throw new Exception("SAP Connection is null !!!");
		
		JCoTable jcoTable = jCoFunction.getTableParameterList().getTable(getSap_table_return());
		
		
		if(jcoTable == null)
			throw new Exception("SAP Table "+ getSap_table_return() +" is null or isEmpty, Please Checked !!!");
		
		return jcoTable;
	}
}
